<pre class='metadata'>
Title: CSS Box Alignment Module Level 3
Shortname: css-align
Level: 3
Group: csswg
Status: ED
Work Status: Refining
ED: https://drafts.csswg.org/css-align/
TR: https://www.w3.org/TR/css-align-3/
Editor: Elika J. Etemad / fantasai, Apple, http://fantasai.inkedblade.net/contact, w3cid 35400
Editor: Tab Atkins Jr., Google, http://xanthir.com/contact/, w3cid 42199
Abstract: This module contains the features of <a href="https://www.w3.org/TR/CSS/">CSS</a> relating to the alignment of boxes within their containers in the various CSS box layout models: block layout, table layout, flex layout, and grid layout. (The alignment of text and inline-level content is defined in [[CSS-TEXT-3]] and [[CSS-INLINE-3]].)
Ignored Terms: table cell, stretch
At Risk: ''[ first | last ]? baseline''
At Risk: the <<overflow-position>> keywords
At Risk: the scrollable-area safety trigger into ''safe'' mode when no <<overflow-position>> is specified
At Risk: the ''legacy'' keyword for 'justify-items'
At Risk: the effect of the <a>box alignment properties</a> on absolutely-positioned boxes with ''left/auto'' offsets
</pre>

<pre class=link-defaults>
spec:css2; type:property;
	text:vertical-align
	text:max-width
	text:max-height
	text:min-width
	text:min-height
spec:css-cascade-3; type:value; text:initial
spec:css-display-3; type:property; text:display
spec:css-flexbox-1; type:dfn;
	text:flex line
spec:css-grid-1; type:dfn;
	text:collapsed gutter
spec:css-inline-3; type:property;
	text:dominant-baseline
	text:alignment-baseline
spec:css-multicol-1; type:dfn;
	text:multi-column container
	text:column box
spec:css-overflow-3; type:dfn; text:scroll container
spec:css-position-3; type:property; text:left
spec:css-writing-modes-3; type:dfn;
	text:dominant baseline
	text:start
	text:end
spec:selectors-3; type:dfn; text:first formatted line
spec:css2; type:dfn; text:line box
</pre>

<style>
.issue th:first-child { text-align: left !important; }
[rowspan] > img { float: right; }
[rowspan] { vertical-align: middle; }
table small { display: block; }

table.align-details { width: 100%; }
.align-details th {
	font: inherit;
	font-style: italic;
	white-space: nowrap; width: 1em;
	vertical-align: baseline; }
.align-details td { vertical-align: baseline; }
</style>

<h2 id="intro">
Introduction</h2>

	CSS Levels 1 and 2 allowed for the alignment of text via 'text-align'
	and the alignment of blocks by balancing ''margin/auto'' margins.
	However, except in table cells,
	vertical alignment was not possible.
	As CSS adds further capabilities,
	the ability to align boxes in various dimensions becomes more critical.
	This module attempts to create a cohesive and common box alignment model to share among all of CSS.

	Note: The alignment of text and inline-level content is defined in [[CSS-TEXT-3]] and [[CSS-INLINE-3]].

	Note: This specification is not intended to change any of the behavior
	defined in <a href="https://www.w3.org/TR/CSS2/">CSS2.1</a>
	when the properties defined here are set to their initial values.
	If implementors or anyone else notices a discrepancy,
	please report this to the CSSWG as an error.

	<em>This section (above) is not normative.</em>

<h3 id="placement">
Module Interactions</h3>

	This module adds some new alignment capabilities
	to the block layout model described in [[!CSS2]] <a href="https://www.w3.org/TR/CSS2/visuren.html">chapters 9</a>
	and <a href="https://www.w3.org/TR/CSS2/visudet.html">10</a>,
	<a href="#justify-block">redefines how overconstrained block-level box margins are resolved</a>,
	and defines the interaction of these new alignment properties
	with the alignment of table cell content using 'vertical-align',
	as defined in [[!CSS2]] <a href="https://www.w3.org/TR/CSS2/tables.html#height-layout">chapter 17</a>.

	The interaction of these properties with
	Grid Layout [[!CSS-GRID-1]]
	and Flexible Box Layout [[!CSS-FLEXBOX-1]]
	is defined in their respective modules.
	The property definitions here supersede those in [[!CSS-FLEXBOX-1]]
	(which have a smaller, earlier subset of permissible values).

	No properties in this module apply to the <code>::first-line</code>
	or <code>::first-letter</code> pseudo-elements.

<h3 id="values">
Value Definitions</h3>

	This specification follows the <a href="https://www.w3.org/TR/CSS2/about.html#property-defs">CSS property definition conventions</a> from [[!CSS2]]
	using the <a href="https://www.w3.org/TR/css-values-3/#value-defs">value definition syntax</a> from [[!CSS-VALUES-3]].
	Value types not defined in this specification are defined in CSS Values &amp; Units [[!CSS-VALUES-3]].
	Combination with other CSS modules may expand the definitions of these value types.

	In addition to the property-specific values listed in their definitions,
	all properties defined in this specification
	also accept the <a>CSS-wide keywords</a> as their property value.
	For readability they have not been repeated explicitly.

<h3 id="partial">
Partial Implementations</h3>

	Since it is expected that support for the features in this module
	will be deployed in stages corresponding to the various layout models affected,
	it is hereby clarified that
	the <a href="https://www.w3.org/TR/CSS/#partial">rules for partial implementations</a>
	that require treating as invalid any unsupported feature
	apply to any alignment keyword
	which is not supported across all layout modules to which it applies
	for layout models in which the implementation supports the property in general.

	For example,
	if an implementation supports 'align-self' in [[CSS-GRID-1]] and [[CSS-FLEXBOX-1]],
	then it must treat ''align-content/start'' as invalid
	unless it is supported in both grid and flex containers.
	However if that same implementation does not support 'align-self' for block-level elements at all,
	then a lack of implementation of ''align-self: start''
	does not trigger this requirement to treat it as invalid.

<h2 id="overview">
Overview of Alignment Properties</h2>

	The <dfn export>box alignment properties</dfn> in CSS are a set of 6 properties
	that control alignment of boxes within other boxes.
	They can be described along two axises:

	<ul>
		<li>which dimension they apply to ([=main axis|main=]/[=inline axis|inline=] vs. [=cross axis|cross=]/[=block axis|block=]), and
		<li>whether they control the position of the box within its parent, or the box's content within itself.
	</ul>

	Note: This specification uses the terms “justify” and “align” to distinguish
	between alignment in the main/inline and cross/block dimensions, respectively.
	The choice is somewhat arbitrary, but having the two terms allows for
	a consistent naming scheme that works across all of CSS's layout models
	(including [[css-flexbox-1#box-model]])

	The following table summarizes the <a>box alignment properties</a>
	and the display types they can apply to.

	<table class=data>
	<colgroup span=1></colgroup>
	<colgroup span=2></colgroup>
	<colgroup span=1></colgroup>
	<thead>
		<tr>
			<th>Common
			<th>Axis
			<th>Aligns
			<th>Applies to
	<tbody>
		<tr>
			<th>'justify-content'
			<td>main/inline
			<td rowspan=2>
				<img src="images/content-example.svg" width=106 height=106 alt="">
				content within element
				<small>(effectively adjusts padding)</small>
			<td rowspan=2>[=block containers=], <a>flex containers</a>, and <a>grid containers</a>
		<tr>
			<th>'align-content'
			<td>cross/block
	<tbody>
		<tr>
			<th>'justify-self'
			<td>inline
			<td rowspan=2>
				<img src="images/self-example.svg" width=106 height=106 alt="">
				element within parent
				<small>(effectively adjusts margins)</small>
			<td>block-level boxes, absolutely-positioned boxes, and <a>grid items</a>
		<tr>
			<th>'align-self'
			<td>cross/block
			<td>absolutely-positioned boxes, <a>flex items</a>, and <a>grid items</a>
	<tbody>
		<tr>
			<th>'justify-items'
			<td>inline
			<td rowspan=2>
				<img src="images/items-example.svg" width=106 height=106 alt="">
				items inside box
				<small>(controls child items&rsquo; ''align/justify-self: auto'')</small>
			<td>[=block containers=] and <a>grid containers</a>
		<tr>
			<th>'align-items'
			<td>cross/block
			<td><a>flex containers</a> and <a>grid containers</a>
	</table>

	Note: The '*-items' properties don't affect the element itself.
	When set on a container,
	they specify the interpretation of any ''*-self: auto'' used on children of the container element.

<h2 id='terms'>
Alignment Terminology</h2>

	Since this module defines alignment properties for all layout modes in CSS,
	some abstract terminology is introduced:

	<dl>
		<dt><dfn export>alignment subject</dfn>
		<dd>
			The <a>alignment subject</a> is the thing or things being aligned by the property.
			For 'justify-self' and 'align-self',
			the <a>alignment subject</a> is the margin box of the box the property is set on,
			and assumes the <a>writing mode</a> of that box.
			For 'justify-content' and 'align-content',
			the <a>alignment subject</a> is defined by the layout mode
			and refers to some aspect of its contents;
			it also assumes the <a>writing mode</a> of the box the property is set on.

		<dt><dfn export>alignment container</dfn>
		<dd>
			The <a>alignment container</a> is the rectangle that the <a>alignment subject</a> is aligned within.
			This is defined by the layout mode,
			but is usually the <a>alignment subject</a>’s containing block,
			and assumes the [=writing mode=] of the box establishing the containing block.

		<dt><dfn export>fallback alignment</dfn>
		<dd>
			Some alignments can only be fulfilled in certain situations
			or are limited in how much space they can consume;
			for example, ''space-between'' can only operate when there is more than one <a>alignment subject</a>,
			and baseline alignment, once fulfilled, might not be enough to absorb all the excess space.
			In these cases a fallback alignment takes effect
			(as defined below)
			to fully consume the excess space.
	</dl>

<h2 id='alignment-values'>
Alignment Keywords</h2>

	All of the alignment properties use a common set of keyword values,
	which are defined in this section.
	Keywords fall into three categories:

	<dl>
		<dt><a href="#positional-values">positional alignment</a>
		<dd>These keywords define alignment as an absolute position within the <a>alignment container</a>.

		<dt><a href="#baseline-values">baseline alignment</a>
		<dd>These keywords define alignment as a relationship
			among the baselines of multiple [=alignment subjects=] within an <a>alignment context</a>.

		<dt><a href="#distribution-values">distributed alignment</a>
		<dd>These keywords define alignment as a distribution of space among <a>alignment subjects</a>.
	</dl>

<h3 id='positional-values'>
Positional Alignment: the ''center'', ''start'', ''end'', ''self-start'', ''self-end'', ''flex-start'', ''flex-end'', ''left'', and ''right'' keywords</h3>

	The <dfn>positional alignment</dfn> keywords specify a position for an <a>alignment subject</a>
	with respect to its <a>alignment container</a>.

	Values have the following meanings:

	<dl dfn-type="value">
		<dt><dfn for="<self-position>, <content-position>, justify-self, align-self, justify-content, align-content">center</dfn> <small>([[#self-alignment|self]], [[#content-distribution|content]])</small>
		<dd>Centers the <a>alignment subject</a> within its <a>alignment container</a>.

		<dt><dfn for="<self-position>, <content-position>, justify-self, align-self, justify-content, align-content">start</dfn> <small>([[#self-alignment|self]], [[#content-distribution|content]])</small>
		<dd>Aligns the <a>alignment subject</a> to be flush with the <a>alignment container</a>’s start edge in the appropriate axis.

		<dt><dfn for="<self-position>, <content-position>, justify-self, align-self, justify-content, align-content">end</dfn> <small>([[#self-alignment|self]], [[#content-distribution|content]])</small>
		<dd>Aligns the <a>alignment subject</a> to be flush with the <a>alignment container</a>’s end edge in the appropriate axis.

		<dt><dfn for="<self-position>, justify-self, align-self">self-start</dfn> <small>([[#self-alignment|self]])</small>
		<dd>Aligns the <a>alignment subject</a> to be flush with the edge of the <a>alignment container</a>
			corresponding to the <a>alignment subject</a>’s start side in the appropriate axis.

		<dt><dfn for="<self-position>, justify-self, align-self">self-end</dfn> <small>([[#self-alignment|self]])</small>
		<dd>Aligns the <a>alignment subject</a> to be flush with the edge of the <a>alignment container</a>
			corresponding to the <a>alignment subject</a>’s end side in the appropriate axis.

		<dt><dfn for="<self-position>, <content-position>, justify-self, align-self, justify-content, align-content">flex-start</dfn> <small>([[#self-alignment|self]], [[#content-distribution|content]])</small>
		<dd><strong>Only used in flex layout.</strong> [[!CSS-FLEXBOX-1]]
			Aligns the <a>alignment subject</a> to be flush with the edge of the <a>alignment container</a>
			corresponding to the <a>flex container</a>’s main-start or cross-start side, as appropriate.

			When used outside of a <a>flex formatting context</a>, this value behaves as ''start''.
			That is, on boxes that are not <a>flex items</a>
			(or pretending to be <a>flex items</a>,
			such as when determining the [=static position=] of an absolutely-positioned box
			that is a child of a <a>flex container</a>),
			this value behaves as ''start'' when used in the <a>self-alignment properties</a>,
			and on boxes that are not <a>flex containers</a>,
			this value behaves as ''start'' when used in the <a>content-distribution properties</a>.

		<dt><dfn for="<self-position>, <content-position>, justify-self, align-self, justify-content, align-content">flex-end</dfn> <small>([[#self-alignment|self]], [[#content-distribution|content]])</small>
		<dd><strong>Only used in flex layout.</strong>
			Aligns the <a>alignment subject</a> to be flush with the edge of the <a>alignment container</a>
			corresponding to the <a>flex container</a>’s main-end or cross-end side, as appropriate.

			When used outside of a <a>flex formatting context</a>, this value behaves as ''end''.
			That is, on boxes that are not <a>flex items</a>
			(or pretending to be <a>flex items</a>,
			such as when determining the [=static position=] of an absolutely-positioned box
			that is a child of a <a>flex container</a>),
			this value behaves as ''end'' when used in the <a>self-alignment properties</a>,
			and on boxes that are not <a>flex containers</a>,
			this value behaves as ''end'' when used in the <a>content-distribution properties</a>.

		<dt><dfn for="justify-content, justify-self, justify-items">left</dfn> <small>(only 'justify-*')</small>
		<dd>Aligns the <a>alignment subject</a> to be flush with
			the <a>alignment container</a>’s <a href="https://www.w3.org/TR/css3-writing-modes/#line-left">line-left</a>
			or <a>physical left</a> edge,
			whichever is in the appropriate axis.

			If the property's axis is not parallel with either left↔right axis,
			this value behaves as ''start''.
			<span class=note>Currently, the only case where the property's axis
			is not parallel with either left↔right axis
			is in a column flexbox.</span>

		<dt><dfn for="justify-content, justify-self, justify-items">right</dfn> <small>(only 'justify-*')</small>
		<dd>Aligns the <a>alignment subject</a> to be flush with
			the <a>alignment container</a>’s <a href="https://www.w3.org/TR/css3-writing-modes/#line-right">line-right</a>
			or <a>physical right</a> edge,
			whichever is in the appropriate axis.

			If the property's axis is not parallel with either left↔right axis,
			this value behaves as ''start''.
			<span class=note>Currently, the only case where the property's axis
			is not parallel with either left↔right axis
			is in a column flexbox.</span>
	</dl>

	Two grammar terms are used to denote certain subsets of these values:

	<dl>
		<dt><<self-position>>
		<dd>
			This set is used by 'justify-self' and 'align-self'
			to align the box within its <a>alignment container</a>,
			and also by 'justify-items' and 'align-items'
			(to specify default values for 'justify-self' and 'align-self').
			<pre class='prod'>
				<dfn>&lt;self-position></dfn> = center | start | end | self-start | self-end |
								flex-start | flex-end
			</pre>
		<dt><<content-position>>
		<dd>
			This set is used by 'justify-content' and 'align-content'
			to align the box's contents within itself.

			<pre class='prod'>
				<dfn>&lt;content-position></dfn> = center | start | end | flex-start | flex-end
			</pre>
	</dl>

	Note: ''left'' and ''right'' are excluded from <<self-position>> and <<content-position>>,
	despite being valid [=positional alignment=] values for 'justify-content'/'justify-self'/'justify-items',
	because they are not allowed in the 'align-*' properties.
	They are instead explicitly included in the 'justify-*' properties’ grammars.

	<aside class=example>
		The ''<self-position>/start'' and ''<self-position>/end'' keywords
		are <a>flow-relative</a>:
		they use the <a>writing mode</a> to determine which side to align to.

		<figure>
			<img src="images/start-inline-tb.svg"
			     width="199" height="125"
			     style="background: white; padding: 8px;"
			     title="inline-axis 'start' alignment in various writing systems"
			     alt="Inline-axis 'start' alignment:
			     Horizontal Latin and Chinese are left-aligned,
			     while Arabic and Hebrew are right-aligned.">
			<img src="images/end-inline-tb.svg"
			     width="199" height="125"
			     style="background: white; padding: 8px;"
			     title="inline-axis 'end' alignment in various writing systems"
			     alt="Inline-axis 'end' alignment:
			     Horizontal Latin and Chinese are right-aligned,
			     while Arabic and Hebrew are left-aligned.">
			<figcaption>
				''<self-position>/start'' vs ''<self-position>/end'' in the <a>inline axis</a>
				(<a href="#flexbox-exception">typically<sup>†</sup></a> 'justify-*')
			</figcaption>
		</figure>

		The ''justify-self/left'' and ''justify-self/right'' keywords
		are absolute (not <a>flow-relative</a>).

		<figure>
			<img src="images/left-inline-tb.svg"
			     width="175" height="125"
			     style="background: white; padding: 8px;"
			     title="'left' alignment in various writing systems"
			     alt="Inline-axis 'left' alignment:
			     Horizontal text is left-aligned, regardless of writing system.">
			<img src="images/right-inline-tb.svg"
			     width="176" height="125"
			     style="background: white; padding: 8px;"
			     title="'right' alignment in various writing systems"
			     alt="Inline-axis 'right' alignment:
			     Horizontal text is right-aligned, regardless of writing system.">
			<figcaption>
				''justify-self/left'' vs ''justify-self/right''
			</figcaption>
		</figure>

		The ''<self-position>/start'' and ''<self-position>/end'' keywords
		have meaning in both the <a lt="inline axis">inline</a> and <a lt="block axis">block</a> axes:
		''<self-position>/start'' always orients to the start of the text
		(top left for left-to-right/top-to-bottom languages like English)
		while ''<self-position>/end'' always orients to the end of the text.

		<figure>
			<img src="images/start-block-tb.svg"
			     width="183" height="125"
			     style="background: white; padding: 8px; padding-bottom: calc(8px + 23px);"
			     title="block-axis 'start' alignment in various writing systems"
			     alt="Block-axis 'start' alignment:
			     Horizontal text is top-aligned in the vertical axis.">
			<img src="images/end-block-tb.svg"
			     width="183" height="125"
			     style="background: white; padding: 8px; padding-top: calc(8px + 23px);"
			     title="block-axis 'end' alignment in various writing systems"
			     alt="Block-axis 'bottom' alignment:
			     Horizontal text is bottom-aligned in the vertical axis.">
			<figcaption>
				''<self-position>/start'' vs ''<self-position>/end'' in the <a>block axis</a>
				(<a href="#flexbox-exception">typically<sup>†</sup></a> 'align-*')
			</figcaption>
		</figure>

		The ''<self-position>/start'' and ''<self-position>/end'' keywords
		use the <a>writing mode</a> of the <a>alignment container</a>,
		to help keep things consistent.
		But if alignment using the <a>alignment subject</a>’s <a>writing mode</a> is needed,
		the ''<self-position>/self-start'' and ''<self-position>/self-end'' keywords can be used.

		<figure>
			<img src="images/self-v-context-start-tb.svg"
			     width="204" height="193"
			     style="background: white; padding: 8px;"
			     title="inline-axis 'start' alignment with LTR context"
			     alt="Inline-axis 'start' alignment in an LTR container:
			     Alignment uses the context’s start direction, so
			     the (RTL) Arabic and Hebrew items
			     are left-aligned alongside the (LTR) Latin and Chinese.">
			<img src="images/self-v-context-self-start-tb.svg"
			     width="229" height="193"
			     style="background: white; padding: 8px;"
			     title="inline-axis 'self-start' alignment with LTR context"
			     alt="Inline-axis 'self-start' alignment in an LTR container:
			     Horizontal Latin and Chinese items are right-aligned,
			     while Arabic and Hebrew items are left-aligned.">
			<figcaption>
				''<self-position>/start'' vs ''<self-position>/self-start'' on the individual items
			</figcaption>
		</figure>
	</aside>

	<aside class=example>
		The behavior of the alignment keywords is analogous in <a>vertical writing modes</a>:
		''<self-position>/start'' and ''<self-position>/end''
		are relative to the start/end of the text in the relevant axis.
		The ''justify-self/left'' and ''justify-self/right'' keywords
		are interpreted as <a>line-left</a> and <a>line-right</a>,
		relative to the “left” and “right” sides of LTR/RTL text.

		<figure>
			<img src="images/start-inline-rl.svg"
			     width="125" height="200"
			     style="background: white; padding: 8px;"
			     title="inline-axis 'start' alignment in various writing systems"
			     alt="Inline-axis 'start' alignment in vertical-rl writing:
			     Vertical Latin and Chinese are top-aligned,
			     while Arabic and Hebrew are bottom-aligned.">
			<img src="images/end-inline-rl.svg"
			     width="125" height="200"
			     style="background: white; padding: 8px;"
			     title="inline-axis 'end' alignment in various writing systems"
			     alt="Inline-axis 'end' alignment in vertical-rl writing:
			     Vertical Latin and Chinese are top-aligned,
			     while Arabic and Hebrew are bottom-aligned.">
			<figcaption>
				''<self-position>/start'' vs ''<self-position>/end'' in the <a>inline axis</a>
				(<a href="#flexbox-exception">typically<sup>†</sup></a> 'justify-*')
			</figcaption>
		</figure>

		<figure>
			<img src="images/left-inline-rl.svg"
			     width="126" height="174"
			     style="background: white; padding: 8px; padding-bottom: calc(8px + 23px);"
			     title="'left' alignment in various writing systems"
			     alt="Inline-axis 'left' alignment in vertical-rl writing:
			     Vertical text is top-aligned, regardless of writing system.">
			<img src="images/right-inline-rl.svg"
			     width="125" height="180"
			     style="background: white; padding: 8px; padding-top: calc(5px + 23px); padding-bottom: 5px;"
			     title="'right' alignment in various writing systems"
			     alt="Inline-axis 'right' alignment in vertical-rl writing:
			     Vertical text is bottom-aligned, regardless of writing system.">
			<figcaption>
				''justify-self/left'' vs ''justify-self/right''
			</figcaption>
		</figure>

		<figure>
			<img src="images/start-block-rl.svg"
			     width="123" height="183"
			     style="background: white; padding: 8px;"
			     title="block-axis 'start' alignment in various writing systems"
			     alt="Block-axis 'start' alignment in vertical-rl writing:
			     Vertical text is top-aligned in the vertical axis.">
			<img src="images/end-block-rl.svg"
			     width="125" height="183"
			     style="background: white; padding: 8px;"
			     title="block-axis 'end' alignment in various writing systems"
			     alt="Block-axis 'bottom' alignment in vertical-rl writing:
			     Vertical text is bottom-aligned in the vertical axis.">
			<figcaption>
				''<self-position>/start'' vs ''<self-position>/end'' in the <a>block axis</a>
				(<a href="#flexbox-exception">typically<sup>†</sup></a> 'align-*')
			</figcaption>
		</figure>

		<figure>
			<img src="images/self-v-context-start-rl.svg"
			     width="162" height="210"
			     style="background: white; padding: 8px; padding-bottom: calc(8px + 30px);"
			     title="inline-axis 'start' alignment with LTR context"
			     alt="Inline-axis 'start' alignment in a vertical-rl LTR container:
			     Alignment uses the context’s start direction, so
			     the (RTL) Arabic and Hebrew items
			     are top-aligned alongside the (LTR) Latin and Chinese.">
			<img src="images/self-v-context-self-start-rl.svg"
			     width="162" height="240"
			     style="background: white; padding: 8px;"
			     title="inline-axis 'self-start' alignment with LTR context"
			     alt="Inline-axis 'self-start' alignment in a vertical-rl LTR container:
			     Horizontal Latin and Chinese items are top-aligned,
			     while Arabic and Hebrew items are bottom-aligned.">
			<figcaption>
				''<self-position>/start'' vs ''<self-position>/self-start'' on the individual items
			</figcaption>
		</figure>
	</aside>

	<div class=note id=flexbox-exception>
		For most layout models (block, table, grid, etc),
		the 'justify-*' properties always align things in the <a>inline axis</a>,
		while the 'align-*' properties always align things in the <a>block axis</a>.

		Flexbox, on the other hand, has 'justify-*' align things in the <a>main axis</a>
		and 'align-*' align things in the <a>cross axis</a>.
		This depends on the value of 'flex-direction':
		when 'flex-direction' is ''flex-direction/row'' or ''flex-direction/row-reverse'',
		it matches the other layout modes
		(<a>inline axis</a> with 'justify-*', <a>block axis</a> with 'align-*');
		when 'flex-direction' is ''flex-direction/column'' or ''flex-direction/column-reverse'',
		it has the opposite correspondence.
	</div>

	<p class='issue'>
		Make it easier to understand the dual-axis nature of "start" and "end" wrt orthogonal flows.

<h3 id='baseline-values'>
Baseline Alignment: the ''baseline'' keyword and ''first''/''last'' modifiers</h3>

	See [[css-writing-modes-3#intro-baselines]].

	<dfn export>Baseline alignment</dfn> is a form of positional alignment
	that aligns multiple <a>alignment subjects</a>
	within a <a>shared alignment context</a>
	(such as cells within a row)
	by matching up their <a>alignment baselines</a>.
	If the position of the <a>alignment subjects</a> within a <a>baseline-sharing group</a>
	is not fully constrained by <a>baseline alignment</a>
	(i.e., they could be shifted within their respective <a>alignment containers</a>
	while maintaining baseline-alignment),
	they are [=fallback alignment|fallback-aligned=] insofar as possible while preserving their <a>baseline alignment</a>.

	The baseline alignment keywords are represented with the <<baseline-position>> grammar term:

	<pre class='prod'>
		<dfn>&lt;baseline-position></dfn> = [ first | last ]? && baseline
	</pre>

	The ''first'' and ''last'' values give a box a <dfn export>baseline alignment preference</dfn>:
	either “first” or “last”, respectively,
	defaulting to “first”.

	Values have the following meanings:

	<dl dfn-type=value dfn-for="justify-self, justify-items, align-content, align-self, align-items, <baseline-position>">
		<dt><dfn>baseline</dfn>
		<dd>
			Computes to ''first baseline'', defined below.

		<dt><dfn lt="first baseline | first">first baseline</dfn>
		<dd>
			Specifies participation in <dfn dfn for export>first-baseline alignment</dfn>:
			aligns the <a>alignment baseline</a> of the box's <a>first baseline set</a>
			with the corresponding baseline
			of its [=baseline-sharing group=].
			See [[#align-by-baseline]] for more details.

			The <a>fallback alignment</a> for ''first baseline'' is
			''safe self-start'' (for [=self-alignment=])
			or ''safe start'' (for [=content-distribution=]).

		<dt><dfn lt="last baseline | last">last baseline</dfn>
		<dd>
			Specifies participation in <dfn dfn for export>last-baseline alignment</dfn>:
			aligns the <a>alignment baseline</a> of the box's <a>last baseline set</a>
			with the corresponding baseline
			of its [=baseline-sharing group=].̣
			See [[#align-by-baseline]] for more details.

			The <a>fallback alignment</a> for ''last baseline'' is
			''safe self-end'' (for [=self-alignment=])
			or ''safe end'' (for [=content-distribution=]).
	</dl>

	When specified for 'align-content',
	these values trigger <a>baseline content-alignment</a>,
	shifting the content of the box within its content box,
	and may also affect the sizing of the box itself.
	See [[#baseline-align-content]].

	When specified for 'align-self'/'justify-self',
	these values trigger <a>baseline self-alignment</a>,
	shifting the entire box within its container,
	which may affect the sizing of its container.
	See [[#baseline-align-self]].

	When [=baseline self-alignment=] is specified on a box,
	[=content distribution=] is performed first,
	then the resulting box and its contents
	are [=baseline self-alignment|self-aligned=]
	However, if the box also has [=baseline content-alignment=] in the same axis
	or if its [=content-distribution property=] in the same axis is ''align-content/normal'',
	its [=used value|used=] [=content-distribution property=] in that axis
	is ''align-content/start'' or ''safe end''
	for a [=baseline alignment preference=] of its [=baseline self-alignment=]
	of “first” or “last”, respectively.

	<p class='issue'>Add example images here.

	If a box does not belong to a <a>shared alignment context</a>,
	then the <a>fallback alignment</a> is used.
	For example, ''align-content: baseline'' on a block box
	falls back to ''align-content/start'' alignment.
	The [=fallback alignment=] is also used to align the [=baseline-sharing group=]
	within its [=alignment container=].

	Note: Because they are equivalent, and ''baseline'' is shorter,
	the CSSOM serializes ''first baseline'' as ''baseline''.
	See [[cssom-1#serializing-css-values]].

	Note: For the somewhat-related 'vertical-align' property,
	due to inconsistent design decisions in CSS2.1,
	''baseline'' is not equivalent to ''first baseline''
	as an inline-level box’s <a>baseline alignment preference</a> depends on 'display'.
	(E.g., ''inline-block'' uses its last baseline by default,
	while ''inline-table'' uses its first baseline by default.)

<h3 id='distribution-values'>
Distributed Alignment: the ''<content-distribution>/stretch'', ''space-between'', ''space-around'', and ''space-evenly'' keywords</h3>

	The <dfn export>distributed alignment</dfn> values are used by 'justify-content' and 'align-content'
	to disperse a container’s extra space among its <a>alignment subjects</a>.

	<figure>
		<img src="images/distribute.svg" alt="space-between | space-around | space-evenly | stretch" width="504" height="218">
		<figcaption>The <a>distributed alignment</a> values</figcaption>
	</figure>

	When space cannot be distributed in this way,
	these values behave as their <a>fallback alignment</a>.
	Each distribution value has an associated default <a>fallback alignment</a>.
	(A future level of this module may allow the <a>fallback alignment</a> to be specified explicitly.)

	<dl dfn-type="value" dfn-for="align-content, justify-content, <content-distribution>">
		<dt><dfn>space-between</dfn>
		<dd>
			The <a>alignment subjects</a> are evenly distributed in the <a>alignment container</a>.
			The first <a>alignment subject</a> is placed flush with the start edge of the <a>alignment container</a>,
			the last <a>alignment subject</a> is placed flush with the end edge of the <a>alignment container</a>,
			and the remaining <a>alignment subjects</a> are distributed so that the spacing between any two adjacent <a>alignment subjects</a> is the same.

			<figure>
				<img src="images/space-between.svg"
				     width="504" height="56"
				     alt="For example, given three items, all excess space is split in two and distributed: one half between the first two and one half between the last two items.">
			</figure>

			The default [=fallback alignment=] for this value is ''safe flex-start''.
			<span class='note'>(For layout modes other than flex layout, ''flex-start'' is identical to ''start''.)</span>

		<dt><dfn>space-around</dfn>
		<dd>
			The <a>alignment subjects</a> are evenly distributed in the <a>alignment container</a>,
			with a half-size space on either end.
			The <a>alignment subjects</a> are distributed so that the spacing between any two adjacent <a>alignment subjects</a> is the same,
			and the spacing before the first and after the last <a>alignment subject</a> is half the size of the other spacing.

			<figure>
				<img src="images/space-around.svg"
				     width="504" height="56"
				     alt="For example, given three items, all excess space is split into sixths and distributed: one sixth at the start, one at the end, and two sixths (one third) each between the first two and between the last two items.">
			</figure>

			The default [=fallback alignment=] for this value is ''safe center''.

		<dt><dfn>space-evenly</dfn>
		<dd>
			The <a>alignment subjects</a> are evenly distributed in the <a>alignment container</a>,
			with a full-size space on either end.
			The <a>alignment subjects</a> are distributed so that the spacing between any two adjacent <a>alignment subjects</a>,
			before the first <a>alignment subject</a>,
			and after the last <a>alignment subject</a>
			is the same.

			<figure>
				<img src="images/space-evenly.svg"
				     width="504" height="56"
				     alt="For example, given three items, all excess space is split into fourths and distributed: to the start, to the end, to between the first two, and to between the last two items.">
			</figure>

			The default [=fallback alignment=] for this value is ''safe center''.

		<dt><dfn>stretch</dfn>
		<dd>
			If the combined size of the <a>alignment subjects</a> is less than the size of the <a>alignment container</a>,
			any <css>auto</css>-sized <a>alignment subjects</a> have their size increased equally (not proportionally),
			while still respecting the constraints imposed by 'max-height'/'max-width'
			(or equivalent functionality),
			so that the combined size exactly fills the <a>alignment container</a>.

			<figure>
				<img src="images/space-stretch.svg"
				     width="504" height="56"
				     alt="For example, given three items, all excess space is split into thirds and distributed: one third to each item.">
			</figure>

			The default [=fallback alignment=] for this value is ''flex-start''.
			<span class='note'>(For layout modes other than flex layout, ''flex-start'' is identical to ''start''.)</span>

			Note: This `align-content/stretch` definition applies to the [=content-distribution properties=];
			the [=self-alignment properties=] 'justify-self'/'align-self' have their own ''justify-self/stretch'' value,
			which can grow <em>or shrink</em> the [=alignment subject=]
			to ensure it exactly fits the [=alignment container=].
	</dl>

	These values are represented with the <<content-distribution>> grammar term:

	<pre class='prod'>
	<dfn>&lt;content-distribution></dfn> = space-between | space-around | space-evenly | stretch
	</pre>

<h3 id='overflow-values'>
Overflow Alignment: the ''safe'' and ''unsafe'' keywords and scroll safety limits</h3>

	In some situations,
	aligning exactly as specified
	would cause the [=alignment subject=] to overflow its [=alignment container=],
	possibly causing data loss.
	For example, if the contents of a sidebar are unconditionally centered,
	items large enough to overflow it might extend beyond the viewport's start edge,
	which can't be scrolled to.

	<div class='example'>
		The figure below illustrates the difference in “safe” versus “unsafe” centering,
		using a column flexbox as an example:

		<figure>
			<style>
			.cross-auto-figure > div {
				margin: 0 auto;
				width: 70px;
				background: #888;
				padding: 0 .5em;
				border-radius: 1em;
				border: 1px solid transparent;
			}
			.cross-auto-figure > div > div {
				border-spacing: 0;
				display: table;
				background: #ddd;
				color: black;
				text-align: center;
				margin: .5em auto;
				padding: .5em;
				border-radius: .5em;
			}
			</style>
			<div style="display:table; margin: 0 auto 1em;">
				<div style="display:table-cell; padding-right: 70px;" class='cross-auto-figure'>
					<div>
						<div>About</div>
						<div style="white-space: nowrap;">Authoritarianism</div>
						<div>Blog</div>
					</div>
				</div>
				<div style="display:table-cell; padding-left: 70px;" class='cross-auto-figure'>
					<div>
						<div>About</div>
						<div style="white-space: nowrap; margin-left: -31px;">Authoritarianism</div>
						<div>Blog</div>
					</div>
				</div>
			</div>
			<figcaption>
				An example of "safe" (on the left)
				vs "unsafe" (on the right)
				centering,
				when the centered item is larger than its container.
			</figcaption>
		</figure>

		The items in the figure on the left are centered unless they overflow,
		in which case all the overflow goes off the end edge,
		while those in the figure on the right are are all strictly centered,
		even if the one that is too long to fit overflows on both sides.

		If the container was placed
		against the left edge of the page,
		the “safe” behavior would be more desirable,
		as the long item would be fully readable,
		rather than clipped by the left edge of the screen.
		In other circumstances,
		the “unsafe” centering behavior might be better,
		as it correctly centers all the items.
	</div>

	To control this situation,
	an <dfn export>overflow alignment</dfn> mode can be explicitly specified.
	“Unsafe” alignment honors the specified alignment mode in overflow situations, even if it causes data loss,
	while “safe” alignment changes the alignment mode in overflow situations in an attempt to avoid data loss.
	The default behavior is to contain the alignment subject within the scrollable area,
	though at the time of writing this safety feature is not yet implemented.

	<pre class='prod'><dfn>&lt;overflow-position></dfn> = unsafe | safe</pre>

	<dl dfn-type="value" dfn-for="<overflow-position>">
		<dt><dfn>safe</dfn>
		<dd>
			If the size of the <a>alignment subject</a> overflows the <a>alignment container</a>,
			the <a>alignment subject</a> is instead aligned as if the alignment mode were ''start''.

		<dt><dfn>unsafe</dfn>
		<dd>
			Regardless of the relative sizes of the <a>alignment subject</a> and <a>alignment container</a>,
			the given alignment value is honored.

		<dt>(no value specified)
		<dd>
			If the <a>overflow alignment</a> isn't explicitly specified,
			the default <a>overflow alignment</a> is a blend of “safe” and “unsafe”.
			See [[#auto-safety]] for details.
	</dl>


<h4 id=auto-safety>
Automatic Overflow Alignment Safety</h4>

	If no [=overflow alignment=] mode is specified for a property,
	the default behavior lies somewhere between ''safe'' and ''unsafe'',
	and also varies by layout mode.

<h5 id=auto-safety-scroll>
Content Distribution for Scroll Containers</h5>

	The default [=overflow alignment=] behavior
	for [=content distribution=] on [=scroll containers=] is ''unsafe''.
	Non-''justify-content/normal'' values of the [=content-distribution properties=] instead
	alter the [=scrollable overflow area=] in order to allow access to the overflowing content.
	See [[#overflow-scroll-position]].

<h5 id=auto-safety-position>
Self-Alignment for Absolutely Positioned Boxes</h5>

	For [=absolutely positioned=] [=alignment subjects=]
	whose relevant [=used value|used=] [=self-alignment property=] is not ''justify-self/normal'',
	the default [=overflow alignment=] behavior is as follows:

	<div algorithm="default overflow self-alignment for abspos">
		1. If the [=alignment subject=] fits within the [=inset-modified containing block=],
			align as specified to the extent possible
			without overflowing the [=inset-modified containing block=].
		2. Otherwise,
			if the [=alignment subject=] fits within the |overflow limit rect|,
			align the [=alignment subject=] such that
			it fully covers the [=inset-modified containing block=]
			and is otherwise aligned as specified to the extent possible
			without overflowing the |overflow limit rect|.
		3. Otherwise,
			start-align the [=alignment subject=] within the |overflow limit rect|
			(similar to ''align-self/safe'').

		For this purpose, the |overflow limit rect| is the bounding rectangle
		of the [=alignment subject's=] [=inset-modified containing block=]
		and its [=original containing block=].
		However, because the [=scrollable overflow area=] of a [=scroll container=]
		can be extended to ensure the visibility of overflowing [=absolutely positioned=] boxes,
		if the [=original containing block=] is generated by a [=scroll container=]
		(and is not its [=fixed containing block=]),
		the |overflow limit rect| is extended to infinity
		in any direction that does not extend into the [=unreachable scrollable overflow region=].
	</div>

	(For [=absolutely-positioned=] [=alignment subjects=] that fail the above condition,
	see [[#auto-safety-default]].)

	Note: These rules constrain the position of the box to minimize overflow
	while honoring the specified alignment insofar as possible,
	and ensuring continuous behavior as the sizes of the boxes change.

<h5 id=auto-safety-default>
All Other Alignment</h5>

	For all other elements:

	1. If the [=alignment subject=] overflows its [=alignment container=],
		align as specified (''unsafe'').
	2. If the [=alignment subject=] would overflow
		the [=scrollable overflow area=] of its nearest ancestor [=scroll container=],
		(thus extending into the “unscrollable” region),
		then its overflow in that direction is limited
		by biasing any remaining overflow to the opposite side.

	Issue: It may not be Web-compatible to implement the “smart” default behavior
	(though we hope so, and believe it to be likely),
	so UAs should pass any feedback on this point to the WG.
	UAs that have not implemented the “smart” default behavior
	must behave as ''safe'' for 'align-content' on [=block containers=]
	and ''unsafe'' otherwise.

<!-- Big Text: *-content

               ███▌   ███▌  █    █▌ █████▌ █████▌ █    █▌ █████▌
 █   █        █▌  █▌ █▌  █▌ █▌   █▌   █▌   █▌     █▌   █▌   █▌
  █ █         █▌     █▌  █▌ ██▌  █▌   █▌   █▌     ██▌  █▌   █▌
███████ ████▌ █▌     █▌  █▌ █▌▐█ █▌   █▌   ████   █▌▐█ █▌   █▌
  █ █         █▌     █▌  █▌ █▌  ██▌   █▌   █▌     █▌  ██▌   █▌
 █   █        █▌  █▌ █▌  █▌ █▌   █▌   █▌   █▌     █▌   █▌   █▌
               ███▌   ███▌  █▌   ▐▌   █▌   █████▌ █▌   ▐▌   █▌
-->

<h2 id='content-distribution'>
Content Distribution: Aligning a Box’s Contents Within Itself</h2>

	<dfn export id="content-distribute" lt="content distribution | content-distribution">Content distribution</dfn> controls alignment of the box's content within its content box.
	It is specified by the <dfn export>content-distribution properties</dfn> 'align-content' and 'justify-content'
	(and their 'place-content' shorthand).

	<div class="figure">
		<img alt="Diagram showing that the alignment of the content within the element is affected." src="images/content-example.svg" width=212 height=212>
	</div>

<h3 id='align-justify-content'>
The 'justify-content' and 'align-content' Properties</h3>

	<pre class="propdef">
	Name: align-content
	Value: normal | <<baseline-position>> | <<content-distribution>> | <<overflow-position>>? <<content-position>>
	Initial: normal
	Applies to: block containers, multicol containers, flex containers, and grid containers
	Inherited: no
	Percentages: n/a
	Computed value: specified keyword(s)
	Animation type: discrete
	</pre>

	<pre class="propdef">
	Name: justify-content
	Value: normal | <<content-distribution>> | <<overflow-position>>? [ <<content-position>> | left | right ]
	Initial: normal
	Applies to: multicol containers, flex containers, and grid containers
	Inherited: no
	Percentages: n/a
	Computed value: specified keyword(s)
	Animation type: discrete
	</pre>

	Aligns the contents of the box as a whole (as the <a>alignment subject</a>)
	within the box itself (as the <a>alignment container</a>):
	along the inline/row/main axis of the box (for 'justify-content')
	or the block/column/cross axis of the box (for 'align-content').
	Values other than <dfn value for="justify-content, align-content">normal</dfn> are defined in [[#alignment-values]], above.

	For all layout modes,
	the <a>alignment subject</a> and <a>alignment container</a>
	both assume the <a>writing mode</a> of the box the '*-content' property is set on.

### Block Containers (Including Table Cells)### {#distribution-block}

	<table class="data align-details">
		<tr>
			<th><a>Alignment Container</a>
			<td>
				The <a>block container</a>’s content box.
		<tr>
			<th><a lt="alignment subject">Alignment Subject(s)</a>
			<td>
				The entire contents of the block, as a unit.
		<tr>
			<th>'align-content' Axis
			<td>
				The <a>block axis</a>.
				If a <<content-distribution>> is specified
				its <a>fallback alignment</a> is used instead.
				If no <<overflow-position>> is specified,
				and the [=block container=] is not a [=scroll container=],
				then alignment is ''align-content/safe''.
		<tr>
			<th>'justify-content' Axis
			<td>
				Does not apply to and has no effect on <a>block containers</a>.
		<tr>
			<th>''align-content/normal'' Behavior
			<td>
				All values other than ''align-content/normal'' force the block container to [=establish an independent formatting context=].

				For table cells, the behavior of ''align-content: normal'' depends on the computed value of 'vertical-align':
				''vertical-align/top'' makes it behave as ''start'' and
				''vertical-align/bottom'' makes it behave as ''end'';
				otherwise ''vertical-align/middle'' makes it behave as ''center'',
				and all other values make it behave as ''baseline''.
				[[!CSS2]]

				''align-content/normal'' otherwise behaves as ''start''.
	</table>

### Multicol Containers ### {#distribution-multicol}

	<table class="data align-details">
		<tr>
			<th><a>Alignment Container</a>
			<td>
				The <a>multi-column container</a>’s content box.
		<tr>
			<th><a lt="alignment subject">Alignment Subject(s)</a>
			<td>
				The column boxes,
				with any spacing inserted between column boxes
				added to the relevant column gaps.
		<tr>
			<th>'align-content' Axis
			<td>
				The <a>block axis</a>,
				treating the column boxes
				(and any column-spanning elements),
				as a singular unit.
				If a <<content-distribution>> is specified
				its <a>fallback alignment</a> is used instead.
		<tr>
			<th>'justify-content' Axis
			<td>
				The <a>inline axis</a>.
		<tr>
			<th>''justify-content/normal'' Behavior
			<td>
				''justify-content/normal'' behaves as ''justify-content/stretch'';
				both are defined as described in the column-sizing rules
				of [[!CSS-MULTICOL-1]].

				In the case of multi-column containers with a non-''column-width/auto'' 'column-width',
				'justify-content' values other than ''justify-content/normal'' or ''justify-content/stretch''
				cause the columns to take their specified 'column-width'
				rather than stretching to fill the container.
				The column boxes are then aligned as specified by 'justify-content'.
	</table>

### Flex Containers ### {#distribution-flex}

	<table class="data align-details">
		<tr>
			<th><a>Alignment Container</a>
			<td>
				The <a>flex container</a>’s content box.
		<tr>
			<th><a lt="alignment subject">Alignment Subject(s)</a>
			<td>
				For 'justify-content',
				the <a>flex items</a> in each <a>flex line</a>.

				For 'align-content',
				the <a>flex lines</a>.
				Note, this only has an effect on <a>multi-line flex containers</a>.
		<tr>
			<th>'align-content' Axis
			<td>
				The <a>cross axis</a>.
		<tr>
			<th>'justify-content' Axis
			<td>
				The 'justify-content' property applies along the <a>main axis</a>,
				but since stretching in the <a>main axis</a> is controlled by 'flex',
				''<content-distribution>/stretch'' behaves as ''flex-start''.
		<tr>
			<th>''justify-content/normal'' Behavior
			<td>
				''justify-content/normal'' behaves as ''<content-distribution>/stretch''.
	</table>

	See [[!CSS-FLEXBOX-1]] for details.

### Grid Containers ### {#distribution-grid}

	<table class="data align-details">
		<tr>
			<th><a>Alignment Container</a>
			<td>
				The <a>grid container</a>’s content box.
		<tr>
			<th><a lt="alignment subject">Alignment Subject(s)</a>
			<td>
				The <a>grid tracks</a> in the appropriate axis,
				with any spacing inserted between tracks
				added to the relevant <a>gutters</a>,
				and treating <a>collapsed gutters</a>
				as a single opportunity for space insertion.
		<tr>
			<th>'align-content' Axis
			<td>
				The <a>block axis</a>,
				aligning the <a>grid rows</a>.
		<tr>
			<th>'justify-content' Axis
			<td>
				The <a>inline axis</a>,
				aligning the <a>grid columns</a>.
		<tr>
			<th>''justify-content/normal'' Behavior
			<td>
				''justify-content/normal'' behaves as ''justify-content/stretch''.
	</table>

	See [[!CSS-GRID-1]] for details.

<h3 id='place-content'>
Content-Distribution Shorthand: the 'place-content' property</h3>

	<pre class="propdef">
	Name: place-content
	Value: <<'align-content'>> <<'justify-content'>>?
	Initial: normal
	Applies to: see individual properties
	Inherited: no
	Percentages: n/a
	Computed value: see individual properties
	Animation type: discrete
	</pre>

	This <a>shorthand property</a> sets both the 'align-content' and 'justify-content' properties in one declaration.
	The first value is assigned to 'align-content'.
	The second value is assigned to 'justify-content';
	if omitted, it is copied from the first value,
	unless that value is a <<baseline-position>>
	in which case it is defaulted to ''start''.

<h3 id="overflow-scroll-position">
Alignment Overflow and Scroll Containers</h3>

	When the <a>content-distribution properties</a> are set
	on a <a>scroll container</a> with an overflowing <a>alignment subject</a>,
	they reduce the clipping of the [=unreachable scrollable overflow region=]
	just enough to ensure that <a>alignment subject</a> can be scrolled
	into its ''align-content/start''-aligned position.

	<div class='example'>
		For example,
		if a scrollable flex container is set to ''justify-content: flex-end''
		(or ''justify-content: flex-start'' with ''flex-flow: row-reverse''),
		its [=in-flow=] content will be initially positioned
		to align the main-end edge of its content to the main-end edge of the flex container,
		and its content will appear to overflow its main-start edge.
		However, the viewer will be able to scroll <em>up</em>
		to view the overflowing [=in-flow=] content,
		just as if ''justify-content: flex-start'' had been specified.
	</div>

	<figure>
		<img src="images/scroll-align-padding.jpg">
		<figcaption>
			Issue: Replace this image with a proper SVG.
		</figcaption>
	</figure>

	Note: The <a>alignment subject</a> is not necessarily
	identical to the <a>scrollable overflow area</a>:
	content overflowing the <a>alignment subject</a>--
	such as an [=out-of-flow=] box--
	grows the <a>scrollable overflow area</a> but not the <a>alignment subject</a>.
	Thus an ''align-content/end''-aligned <a>scroll container</a>
	might not be initially scrolled all the way to the bottom,
	and positioned content can still be clipped
	if it is further into the [=unreachable scrollable overflow region=]
	than the [=in-flow=] content forming the [=alignment subject=].

	<figure>
		<img src="images/scroll-align-overflow.jpg" alt="">
		<figcaption>
			Overflow is not part of the <a>alignment subject</a>,
			even for a <a>scroll container</a>.

			Issue: Replace this image too.
		</figcaption>
	</figure>

	Note: The presence of scrollbars can change
	the size of the [=scroll container’s=] [=content box=]--
	and thus the size of the [=alignment container=]
	and/or [=alignment subject=].

<h3 id="baseline-align-content">
Baseline Content-Alignment</h3>

	The content of boxes participating in row-like layout contexts (<a>shared alignment contexts</a>)
	can be baseline-aligned to each other.
	<dfn export lt="baseline content-alignment|first-baseline content-alignment|last-baseline content-alignment">Baseline content-alignment</dfn> effectively increases the <strong>padding</strong> on the box
	to align the <a>alignment baseline</a> of its contents
	with that of other baseline-aligned boxes in its <a>baseline-sharing group</a>.

	[=Baseline content-alignment=] can only apply if the 'align-content' axis
	is parallel with the box's [=block axis=]
	(i.e. it does not apply to “column” [=flex containers=]);
	otherwise the [=fallback alignment=] is used.


	The set of boxes that participate in <a>baseline content-alignment</a>
	depends on the layout model:

	<dl>
		<dt>Table Cells:
		<dd>
			A ([=non-replaced=]) <a>table cell</a> participates in
			first/last <a>baseline content-alignment</a>
			in its startmost/endmost row
			if its inline axis is parallel to that of the table itself and
			its computed 'align-content' is ''first baseline'' (''last baseline'').

			Note: <a>Baseline content-alignment</a>
			of cells sharing a column is not supported;
			however this may be added in a future level
			if there is sufficient demand and implementer interest.

		<dt>Flex Items:
		<dd>
			A [=non-replaced=] <a>flex item</a> participates in
			first/last <a>baseline content-alignment</a>
			in its flex line if
			its computed 'align-content' is ''first baseline''/''last baseline''
			and its <a>inline axis</a> is parallel to the <a>main axis</a>.

		<dt>Grid Items:
		<dd>
			A [=non-replaced=] <a>grid item</a> participates in
			first/last <a>baseline content-alignment</a>
			in its startmost/endmost row or column
			(whichever is parallel to its <a>inline axis</a>)
			and if its computed 'align-content' is ''first baseline''/''last baseline''.
	</dl>

	Additionally,
	in order to participate in <a>baseline content-alignment</a>
	it must also have a <dfn noexport>coordinated self-alignment preference</dfn>,
	to guarantee that the box lines up the relevant edge
	with other boxes in its [=baseline-sharing group=].
	That is, the box’s [=start=] ([=end=]) [=margin edge=]
	must be intended to align--
	and actually align--
	to the corresponding [=box edge|edge=] of its [=containing block=]
	when its [=baseline alignment preference=] is “first” (“last”).
	It otherwise takes its <a>fallback alignment</a>.

	<details class="note">
		<summary>When is a self-alignment preference coordinated?</summary>

		A box’s [=start=] [=margin edge=] is aligned
		to the corresponding edge of its [=containing block=]
		and it has a [=coordinated self-alignment preference=]
		for a “first” [=baseline alignment preference=] when,
		in the relevant axis:

		* There are no ''margin/auto'' [=margins=] and
			the relevant <a>self-alignment property</a>
			either is or aligns identically to
			''align-self/stretch'' or ''self-start''; or
		* There is only an ''margin/auto'' [=end=]-edge [=margin=],
			which absorbs any positive free space
			and disables the effects of any [=self-alignment property=],
			<em>and</em>
			its [=margin box=] does not overflow its [=containing block=]
			under circumstances that would cause it
			to effectively end-align instead
			(such as having a [=containing block=] with an opposite [=writing mode=]).

		A box’s [=end=] [=margin edge=] is aligned
		to the corresponding edge of its [=containing block=]
		and it has a [=coordinated self-alignment preference=]
		for a “last” [=baseline alignment preference=] when,
		in the relevant axis:

		* There are no ''margin/auto'' [=margins=] and
			the relevant <a>self-alignment property</a>
			either is or aligns identically to ''self-end''
			<em>and</em>
			its self-alignment is what would result
			from an ''unsafe'' [=overflow alignment=]; or
		* There is only an ''margin/auto'' [=start=]-edge [=margin=],
			which absorbs any positive free space
			and disables the effects of any [=self-alignment property=]
			<em>and</em>
			its [=margin box=] does not overflow its [=containing block=]
			under circumstances that would cause it
			to effectively start-align instead.
	</details>

	See [[#align-by-baseline]] for additional details.
	<a>Baseline content-alignment</a> can increase the intrinsic size of the box.

<!--
                   ██████  ████████ ██       ████████
 ██   ██          ██    ██ ██       ██       ██
  ██ ██           ██       ██       ██       ██
█████████ ███████  ██████  ██████   ██       ██████
  ██ ██                 ██ ██       ██       ██
 ██   ██          ██    ██ ██       ██       ██
                   ██████  ████████ ████████ ██
-->

<h2 id='self-alignment'>
Self-Alignment: Aligning the Box Within Its Parent</h2>

	<dfn export id="self-align">Self-alignment</dfn> controls alignment of the box within its containing block.
	It is specified by the <dfn export>self-alignment properties</dfn> 'align-self' and 'justify-self'
	(and their 'place-self' shorthand).

	<div class="figure">
		<img alt="Diagram showing that the alignment of the element within its containing block is affected." src="images/self-example.svg" width=212 height=212>
	</div>

<h3 id='justify-self-property'>
Inline-Axis (or Main-Axis) Self-Alignment: the 'justify-self' property</h3>

	<pre class="propdef">
	Name: justify-self
	Value: auto | normal | stretch | <<baseline-position>> | <<overflow-position>>? [ <<self-position>> | left | right ]
	Initial: auto
	Applies to: block-level boxes, absolutely-positioned boxes, and grid items
	Inherited: no
	Percentages: n/a
	Computed value: specified keyword(s)
	Animation type: discrete
	</pre>

	Justifies the box (as the [=alignment subject=])
	within its containing block (as the [=alignment container=])
	along the inline/row/main axis of the [=alignment container=]:
	the box's outer edges are aligned within its <a>alignment container</a>
	<a href="#alignment-values">as described by its alignment value</a>.
	Values have the following meanings:

	<dl dfn-type=value dfn-for=justify-self>
		: <dfn>auto</dfn>
		::
			Behaves as ''justify-self/normal'' if the box has no parent,
			or when determining the actual position of an absolutely positioned box.
			It behaves as the computed 'justify-items' value of the parent box
			(minus any ''legacy'' keywords)
			otherwise
			(including when determining the <em>static</em> position
			of an absolutely positioned box).

		: <dfn>normal</dfn>
		::
			Represents the “default” alignment for the layout mode.
			Its behavior depends on the layout mode, as described below.

		: <dfn>stretch</dfn>
		::
			When the box’s [=computed value|computed=] 'width'/'height'
			(as appropriate to the axis)
			is ''width/auto''
			and neither of its margins (in the appropriate axis) are ''margin/auto'',
			sets the box’s used size to the length necessary to make its outer size
			as close to filling the <a>alignment container</a> as possible
			while still respecting the constraints imposed by 'min-height'/'min-width'/'max-height'/'max-width'.

			Unless otherwise specified, this value falls back to ''flex-start'' generally,
			and to ''self-start'' or ''self-end''
			if the box has also specified
			<a>first baseline</a> or <a>last baseline</a> <a>baseline content-alignment</a> (respectively)
			in the same axis.

			Note: The ''justify-self/stretch'' keyword can cause elements to shrink,
			to fit their container.

		: <<baseline-position>>
		::
			Indicates <a>baseline self-alignment</a>,
			as defined in [[#baseline-values]],
			[[#baseline-align-self]],
			and [[#baseline-rules]].

		: <<overflow-position>>? <<self-position>>
		::
			Defined in [[#alignment-values]], above.
	</dl>

	Values other than ''justify-self/stretch'' cause a 'width'/'height' of ''width/auto''
	to be treated as ''width/fit-content''.

	Note: ''margin/auto'' margins,
	because they effectively adjust the size of the margin area,
	take precedence over 'justify-self'.

### Block-Level Boxes ### {#justify-block}

	<table class="data align-details">
		<tr>
			<th>'justify-self' Axis
			<td>
				The block’s <a>containing block’s</a> <a>inline axis</a>, generally.
				The [=static-position containing block=]’s [=inline axis=]
				when determining the [=static position=].
		<tr>
			<th><a>Alignment Container</a>
			<td>
				The box's <a>containing block</a>,
				except that for block-level elements that establish a <a>block formatting context</a>
				and are placed next to a float,
				the <a>alignment container</a> is reduced by the space taken up by the float,
				assuming the <a>writing mode</a> of the <a>containing block</a>.
		<tr>
			<th><a>Alignment Subject</a>
			<td>
				The block's margin box,
				assuming the <a>writing mode</a> of the block.
		<tr>
			<th>''justify-self/normal'' Behavior
			<td>
				The box lays out according to the default rules for block layout
				(see <a href="https://www.w3.org/TR/CSS2/visudet.html#Computing_widths_and_margins">CSS2.1&sect;10.3</a>).
		<tr>
			<th>Other Details
			<td>
				In terms of CSS2.1 block-level formatting [[!CSS2]],
				the rules for “over-constrained” computations in <a href="https://www.w3.org/TR/CSS2/visudet.html#blockwidth">section 10.3.3</a>
				are ignored in favor of alignment as specified here
				and the used value of the margin properties are therefore not adjusted to correct for the over-constraint.

				This property does not apply to floats.
	</table>

	<div class="example">
		The effect of these rules is that an auto-sized block-level table,
		for example, can be aligned while still having side margins.
		If the table's max-content size is narrower than its containing block,
		then it is shrink-wrapped to that size and aligned as specified.
		If the table's max-content size is wider, then it fills its containing block,
		and the margins provide appropriate spacing from the containing block edges.
	</div>

### Absolutely-Positioned Boxes ### {#justify-abspos}

	This section describes the effect of 'justify-self'
	on how the margin box of an absolutely-positioned box
	is positioned with respect to its (absolute-positioning) containing block.

	<table class="data align-details">
		<tr>
			<th>'justify-self' Axis
			<td>
				The block’s containing block’s <a>inline axis</a>.
		<tr>
			<th><a>Alignment Container</a>
			<td>
				The box's <a>containing block</a>,
				as modified by the [=inset properties=] ('top'/'right'/'bottom'/'left'),
				assuming the <a>writing mode</a> of the <a>containing block</a>.
				If both inset properties in the relevant axis are ''left/auto'',
				then use the box’s <a>static-position rectangle</a>
				(i.e. set both insets to the box’s <a>static position</a>)
				and assume the [=writing mode=] of the [=static-position containing block=].
		<tr>
			<th><a>Alignment Subject</a>
			<td>
				The box's margin box,
				assuming the <a>writing mode</a> of the box.
		<tr>
			<th>''justify-self/normal'' Behavior
			<td>
				Behaves as ''justify-self/stretch'' or ''justify-self/start'',
				depending on the type of box.
				See [[css-position-3#abspos-layout]].
		<tr>
			<th>Other Details
			<td>
				In terms of CSS2.1 formatting [[!CSS2]],
				the rules for “over-constrained” computations in <a href="https://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-width">section 10.3.7</a>
				are ignored in favor of alignment as specified here,
				and the used value of the [=inset properties=] are not adjusted to correct for the over-constraint.

				Values other than ''justify-self/stretch'' or ''justify-self/normal''
				cause <a href="https://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-width">non-replaced absolutely-positioned boxes</a>
				to use <a>fit-content sizing</a> for calculating ''width/auto'' sizes
				in the affected axis.

				Note that ''justify-self/stretch'' <em>does</em> cause replaced absolutely-positioned boxes
				to fill their containing block
				just as non-replaced ones do.

				Note: If only one inset property is ''top/auto'',
				the computations in <a href="https://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-width">CSS2 section 10.3.7</a>
				fully determine its size and position,
				and 'justify-self' has no effect.
				(If both are ''top/auto'',
				then the box is statically-positioned,
				see above,
				and can be aligned within the <a>static-position rectangle</a>.)
	</table>

### Table Cells ### {#justify-cell}

	This property does not apply to table cells,
	because their position and size is fully constrained by table layout.

### Flex Items ### {#justify-flex}

	This property does not apply to <a>flex items</a>,
	because there is more than one item in the <a>main axis</a>.
	See 'flex' for stretching and 'justify-content' for <a>main-axis</a> alignment. [[!CSS-FLEXBOX-1]]

### Grid Items ### {#justify-grid}

	<table class="data align-details">
		<tr>
			<th>'justify-self' Axis
			<td>
				The grid’s [=inline axis=].
		<tr>
			<th><a>Alignment Container</a>
			<td>
				The <a>grid item’s</a> <a>grid area</a>,
				assuming the <a>writing mode</a> of the <a>grid container</a>.
		<tr>
			<th><a>Alignment Subject</a>
			<td>
				The <a>grid item’s</a> margin box,
				assuming the <a>writing mode</a> of the <a>grid item</a>.
		<tr>
			<th>''justify-self/normal'' Behavior
			<td>
				Sizes as either ''justify-self/stretch'' (typical [=non-replaced elements=])
				or ''justify-self/start'' (typical [=replaced elements=]);
				see [[css-grid-1#grid-item-sizing|Grid Item Sizing]] in [[!CSS-GRID-1]].
				The resulting box is then start-aligned.
	</table>

	See [[!CSS-GRID-1]] for details.

<h3 id='align-self-property'>
Block-Axis (or Cross-Axis) Self-Alignment: the 'align-self' property</h3>

	<pre class="propdef">
	Name: align-self
	Value: auto | normal | stretch | <<baseline-position>> | <<overflow-position>>? <<self-position>>
	Initial: auto
	Applies to: flex items, grid items, and absolutely-positioned boxes
	Inherited: no
	Percentages: n/a
	Computed value: specified keyword(s)
	Animation type: discrete
	</pre>

	Aligns the box (as the [=alignment subject=])
	within its containing block (as the [=alignment container=])
	along the block/column/cross axis of the [=alignment container=]:
	the box's outer edges are aligned within its <a>alignment container</a>
	<a href="#alignment-values">as described by its alignment value</a>.
	Values have the following meanings:

	<dl dfn-type=value dfn-for=align-self>
		: <dfn>auto</dfn>
		::
			Behaves as ''align-self/normal'' if the box has no parent,
			or when determining the actual position of an absolutely positioned box.
			It behaves as the computed 'align-items' value of the parent box
			(minus any ''legacy'' keywords)
			otherwise
			(including when determining the <em>static</em> position
			of an absolutely positioned box).

		: <dfn>normal</dfn>
		::
			Represents the “default” alignment for the layout mode,
			as defined below.

		: <dfn>stretch</dfn>
		::
			As defined for 'justify-self' in [[#justify-self-property]].

		: <<baseline-position>>
		::
			Indicates <a>baseline self-alignment</a>,
			as defined in [[#baseline-values]],
			[[#baseline-align-self]],
			and [[#baseline-rules]].

		: <<overflow-position>>? <<self-position>>
		::
			Defined in [[#alignment-values]], above.
	</dl>

	Note: ''margin/auto'' margins,
	because they effectively adjust the size of the margin area,
	take precedence over 'align-self'.

### Block-Level Boxes ### {#align-block}

	The 'align-self' property does not apply to block-level boxes
	(including floats),
	because there is more than one item in the <a>block axis</a>.

### Absolutely-Positioned Boxes ### {#align-abspos}

	This section describes the effect of 'align-self'
	on how the margin box of an absolutely-positioned box
	is positioned with respect to its (absolute-positioning) containing block.

	<table class="data align-details">
		<tr>
			<th>'align-self' Axis
			<td>
				The box’s <a>containing block’s</a> <a>block axis</a>, generally.
				The [=static-position containing block=]’s [=block axis=]
				when determining the [=static position=].
		<tr>
			<th><a>Alignment Container</a>
			<td>
				The box's <a>containing block</a>,
				as modified by the [=inset properties=]
				('top'/'right'/'bottom'/'left'),
				assuming the <a>writing mode</a> of the <a>containing block</a>.
				If both inset properties in the relevant axis are ''left/auto'',
				then use the box’s <a>static-position rectangle</a>
				(i.e. set both insets to the box’s <a>static position</a>)
				and assume the [=writing mode=] of the [=static-position containing block=].
		<tr>
			<th><a>Alignment Subject</a>
			<td>
				The box’s margin box,
				assuming the <a>writing mode</a> of the box.
		<tr>
			<th>''align-self/normal'' Behavior
			<td>
				Behaves as ''align-self/stretch'' or ''align-self/start'',
				depending on the type of box.
				See [[css-position-3#abspos-layout]].
		<tr>
			<th>Other Details
			<td>
				In terms of CSS2.1 formatting [[!CSS2]],
				the rules for "over-constrained" computations in <a href="https://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-height">section 10.6.4</a>
				are ignored in favor of alignment as specified here
				and the used value of the [=inset properties=] are not adjusted to correct for the over-constraint.

				Values other than ''justify-self/stretch'' or ''justify-self/normal''
				cause <a href="https://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-height">non-replaced absolutely-positioned boxes</a>
				to use <a>fit-content sizing</a> for calculating ''height/auto'' sizes
				in the affected axis.

				Note that ''justify-self/stretch'' does cause replaced absolutely-positioned boxes
				to fill their containing block
				just as non-replaced ones do.

				Note: If only one inset property is ''top/auto'',
				the computations in <a href="https://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-height">CSS2 section 10.6.4</a>
				fully determine its size and position,
				and 'align-self' has no effect.
				(If both are ''top/auto'',
				then the box is statically-positioned,
				see above,
				and can be aligned within the <a>static-position rectangle</a>.)

	</table>

### Table Cells ### {#align-cell}

	This property does not apply to table cells,
	because their position and size is fully constrained by table layout.

### Flex Items ### {#align-flex}

	<table class="data align-details">
		<tr>
			<th>'align-self' Axis
			<td>
				The <a>flex container’s</a> <a>cross axis</a>.
		<tr>
			<th><a>Alignment Container</a>
			<td>
				The <a>flex line</a> the <a>flex item</a> is in,
				assuming the <a>writing mode</a> of the <a>flex container</a>.
		<tr>
			<th><a>Alignment Subject</a>
			<td>
				The <a>flex item’s</a> margin box,
				assuming the <a>writing mode</a> of the <a>flex item</a>.
		<tr>
			<th>''align-self/normal'' Behavior
			<td>
				Behaves as ''align-self/stretch''.
	</table>

	See [[!CSS-FLEXBOX-1]] for details.

### Grid Items ### {#align-grid}

	<table class="data align-details">
		<tr>
			<th>'align-self' Axis
			<td>
				The grid’s [=block axis=].
		<tr>
			<th><a>Alignment Container</a>
			<td>
				The [=grid item’s=] <a>grid area</a>,
				assuming the <a>writing mode</a> of the <a>grid container</a>.
		<tr>
			<th><a>Alignment Subject</a>
			<td>
				The <a>grid item’s</a> margin box,
				assuming the <a>writing mode</a> of the <a>grid item</a>.
		<tr>
			<th>''align-self/normal'' Behavior
			<td>
				Sizes as either ''justify-self/stretch'' (typical [=non-replaced elements=])
				or ''justify-self/start'' (typical [=replaced elements=]);
				see [[css-grid-1#grid-item-sizing|Grid Item Sizing]] in [[!CSS-GRID-1]].
				The resulting box is then start-aligned.
	</table>

	See [[!CSS-GRID-1]] for details.

<h3 id='place-self-property'>
Self-Alignment Shorthand: the 'place-self' property</h3>

	<pre class="propdef">
	Name: place-self
	Value: <<'align-self'>> <<'justify-self'>>?
	Initial: auto
	Applies to: see individual properties
	Inherited: no
	Percentages: n/a
	Computed value: see individual properties
	Animation type: discrete
	</pre>

	This <a>shorthand property</a> sets
	both the 'align-self' and 'justify-self' properties
	in a single declaration.
	The first value is assigned to 'align-self'.
	The second value is assigned to 'justify-self';
	if omitted, it is copied from the first value.

<h3 id="baseline-align-self">
Baseline Self-Alignment</h3>

	Boxes participating in row-like layout contexts (<a>shared alignment contexts</a>)
	can be baseline-aligned to each other.
	<dfn export lt="baseline self-alignment|first-baseline self-alignment|last-baseline self-alignment">Baseline self-alignment</dfn> effectively increases the <strong>margins</strong> on the box
	to align its <a>alignment baseline</a>
	with that of other baseline-aligned boxes in its <a>baseline-sharing group</a>.

	The set of boxes that participate in <a>baseline self-alignment</a>
	depends on the layout model:

	<dl>
		<dt>Flex Items:
		<dd>
			A <a>flex item</a> participates in
			first/last <a>baseline self-alignment</a>
			in its flex line
			if its computed 'align-self' is ''first baseline''/''last baseline''.
			See [[!CSS-FLEXBOX-1]] for details.

		<dt>Grid Items:
		<dd>
			A <a>grid item</a> participates in
			first/last <a>baseline self-alignment</a>
			in its startmost/endmost row or column
			if its 'align-self' or 'justify-self' property (respectively)
			computes to ''first baseline''/''last baseline''.
	</dl>

	See [[#align-by-baseline]] for exact details.
	<a>Baseline self-alignment</a> can increase the intrinsic size contribution of the box.

<h3 id="abspos-sizing">
Effects on Sizing of Absolutely Positioned Boxes with Static-Position Insets</h3>

	For absolutely-positioned boxes
	whose inline-axis offsets are both ''left/auto'',
	the <a>available space</a> for calculating the <a>inline size</a>
	is also affected by alignment.

	Note: In [[CSS2]], the [=available space=] is keyed off of the 'direction' property
	of the <a>static-position containing block</a>.
	(See <a href="https://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-width">CSS2&sect;10.3.7</a>
	and <a href="https://www.w3.org/TR/CSS2/visudet.html#abs-replaced-width">CSS2&sect;10.3.8</a>.)
	Fundamentally these rules set one of the ''left/auto'' insets
	(by default, the start-edge inset)
	to the corresponding edge of the <a>static-position rectangle</a>
	and the other to the corresponding edge of the <a>containing block</a>
	(i.e. set the inset to zero).
	Just as the <a>self-alignment properties</a>
	replace the <a>containing block</a>’s 'direction' lookup for placement,
	they also replace this lookup for sizing,
	as specified here.

	Thus,
	when interpreting the rules in
	<a href="https://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-width">CSS2&sect;10.3.7</a>
	and <a href="https://www.w3.org/TR/CSS2/visudet.html#abs-replaced-width">CSS2&sect;10.3.8</a>,
	wherever the 'direction' property of the <a>static-position containing block</a> is referenced,
	instead reference the value of the 'align-self' or 'justify-self' property
	(whichever is defined to apply to the relevant axis),
	treating left-equivalent alignment as defined for ''ltr''
	and right-equivalent alignment as defined for ''rtl''.
	Treat ''justify-self/normal'' as ''start''
	and any <a>distributed alignment</a> value as its <a>fallback alignment</a>.

	In the case of ''justify-self/center'' alignment,
	the [=available space=] for the box is
	double the distance between the center of the [=static-position rectangle=]
	and the closest edge of the [=containing block=]
	in the relevant axis.

	<figure>
		<img src="images/place-content-abspos.svg" width=480 height=330
		     alt="Start alignment sizes into the space between
		          the start edge of the static-position rectangle and the end edge of the containing block.
		          End alignment sizes into the space between
		          the end edge of the static-position rectangle and the start edge of the containing block.
		          Center alignment sizes into the space between
		          the two edges of the static-position rectangle.">
		<figcaption>
			Instead of always sizing
			within the available space between
			the <a>inline-start</a> <a>static position</a>
			and the <a>inline-end</a> <a>containing block</a> edge
			as specified in [[CSS2]],
			an absolutely-positioned element with ''left/auto'' insets
			will be sized with reference to
			the <a>static-position rectangle</a>’s edge(s)
			<em>most appropriate</em> to its specified <a>self-alignment</a>.
		</figcaption>
	</figure>

	<div class="example">
		For example,
		when the box’s <a>containing block</a>’s 'direction' is ''ltr''
		and its own 'justify-self' is ''justify-content/end'',
		apply the rules for ''direction: rtl'';
		when 'direction' is ''rtl'' and 'justify-content' is ''justify-content/space-between'',
		apply the rules for ''direction: rtl'';
		etc.
		For the case of ''justify-content/center'' (or its equivalent),
		set both sides to match the <a>static position</a>.
		The absolutely-positioned box is then sized into
		the resulting space (floored at zero).
	</div>


	Note: The 'align-self'/'justify-self' properties
	can also modify additional aspects of sizing:
	for example, ''justify-self: stretch'' will replace
	“shrink-to-fit” (<a lt="fit-content sizing">fit-content</a>) sizing into the <a>available space</a>
	with <a>stretch-fit sizing</a> (consuming all of the <a>available space</a>).
	This is an independent effect from the available space adjustment here.

	Note: This only affect how [=available space=] is calculated
	for sizing the absolutely-positioned box;
	its alignment is as specified in previous sections.

<!--
                  ████ ████████ ████████ ██     ██  ██████
 ██   ██           ██     ██    ██       ███   ███ ██    ██
  ██ ██            ██     ██    ██       ████ ████ ██
█████████ ███████  ██     ██    ██████   ██ ███ ██  ██████
  ██ ██            ██     ██    ██       ██     ██       ██
 ██   ██           ██     ██    ██       ██     ██ ██    ██
                  ████    ██    ████████ ██     ██  ██████
-->

<h2 id='default-alignment'>
Default Alignment</h2>

	The 'align-items' and 'justify-items' properties
	(and their 'place-items' shorthand)
	set the default 'align-self' and 'justify-self' behavior of the element’s child boxes.

	<div class="figure">
		<img alt="Diagram showing that the alignment of grid items within the element is affected." src="images/items-example.svg" width=212 height=212>
	</div>

<h3 id='justify-items-property'>
Inline-Axis (or Main-Axis) Default Alignment: the 'justify-items' property</h3>

	<pre class="propdef">
	Name: justify-items
	Value: normal | stretch | <<baseline-position>> | <<overflow-position>>? [ <<self-position>> | left | right ] | legacy | legacy && [ left | right | center ]
	Initial: legacy
	Applies to: all elements
	Inherited: no
	Percentages: n/a
	Computed value: specified keyword(s), except for ''justify-items/legacy'' (see prose)
	Animation type: discrete
	</pre>

	This property specifies the default 'justify-self' for all of the child boxes
	(including anonymous boxes)
	participating in this box's formatting context.
	Values have the following meanings:

	<dl dfn-type="value" dfn-for="justify-items">
		<dt><dfn>legacy</dfn>
		<dd>
			This keyword causes the value to effectively inherit into descendants.

			If the ''legacy'' keyword appears on its own
			(without an accompanying ''left'', ''right'', or ''<content-position>/center'' keyword):
			if the <a>inherited value</a> of ''justify-items'' includes the ''legacy'' keyword,
			this value computes to the <a>inherited value</a>;
			otherwise it computes to ''justify-items/normal''.

			When ''justify-self:auto'' references the value of 'justify-items',
			only the alignment keyword, not the ''legacy'' keyword, is referenced by it.
			It exists to implement the legacy alignment behavior of HTML's <code>&lt;center></code> element and <code>align</code> attribute.
	</dl>

	Other values have no special handling and are merely referenced by 'justify-self'.

<h3 id='align-items-property'>
Block-Axis (or Cross-Axis) Default Alignment: the 'align-items' property</h3>

	<pre class="propdef">
	Name: align-items
	Value: normal | stretch | <<baseline-position>> | <<overflow-position>>? <<self-position>>
	Initial: normal
	Applies to: all elements
	Inherited: no
	Percentages: n/a
	Computed value: specified keyword(s)
	Animation type: discrete
	</pre>

	This property specifies the default 'align-self' for all of the child boxes
	(including anonymous boxes)
	participating in this box's formatting context.

	Values have no special handling and are merely referenced by 'align-self'.

<h3 id='place-items-property'>
Default Alignment Shorthand: the 'place-items' property</h3>

	<pre class="propdef">
	Name: place-items
	Value: <<'align-items'>> <<'justify-items'>>?
	Initial: see individual properties
	Applies to: all elements
	Inherited: no
	Percentages: n/a
	Computed value: see individual properties
	Animation type: discrete
	</pre>

	This <a>shorthand property</a> sets
	both the 'align-items' and 'justify-items' properties
	in a single declaration.
	The first value is assigned to 'align-items'.
	The second value is assigned to 'justify-items';
	if omitted, it is copied from the first value.


<!--
 ██████      ███    ████████   ██████
██    ██    ██ ██   ██     ██ ██    ██
██         ██   ██  ██     ██ ██
██   ████ ██     ██ ████████   ██████
██    ██  █████████ ██              ██
██    ██  ██     ██ ██        ██    ██
 ██████   ██     ██ ██         ██████
-->

<h2 id='gaps'>
Gaps Between Boxes</h2>

	While 'margin' and 'padding' can be used to specify visual spacing around individual boxes,
	it's sometimes more convenient to globally specify spacing
	<em>between</em> adjacent boxes within a given layout context,
	particularly when the spacing is different between sibling boxes
	as opposed to between the first/last box and the container's edge.

	The 'gap' property,
	and its 'row-gap' and 'column-gap' sub-properties,
	provide this functionality for
	<a href="http://www.w3.org/TR/css3-multicol/">multi-column</a>,
	<a href="http://www.w3.org/TR/css-flexbox/">flex</a>,
	and <a href="http://www.w3.org/TR/css-grid/">grid layout</a>.

<h3 id='column-row-gap'>
Row and Column Gutters: the 'row-gap' and 'column-gap' properties</h3>

	<pre class='propdef'>
	Name: row-gap, column-gap
	Value: normal | <<length-percentage [0,∞]>>
	Initial: normal
	Applies to: <a>multi-column containers</a>, <a>flex containers</a>, <a>grid containers</a>
	Inherited: no
	Percentages: see [[#gap-percent]]
	Computed value: specified keyword, else a computed <<length-percentage>> value
	Animation type: by computed value type
	</pre>

	These properties specify fixed-length <dfn export lt="gutter">gutters</dfn>
	between items in the container,
	adding space between them--
	in a manner similar to the ''justify-content/space-between'' keyword
	of the <a>content-distribution properties</a>,
	but of a fixed size instead of as a fraction of remaining space.
	The 'column-gap' property specifies spacing between “columns”,
	separating boxes in the container's <a>inline axis</a>
	similar to <a>inline-axis</a> margin;
	while 'row-gap' indicates spacing between “rows”,
	separating boxes in the container's <a>block axis</a>.

	Values have the following meanings:

	<dl dfn-type=value dfn-for="row-gap, column-gap, gap">
		: <<length-percentage [0,∞]>>
		::
			Specifies a gap between “rows” or “columns”,
			as defined by the layout modes to which it applies;
			see subsections below for details.

			Negative values are invalid.
			For percentages,
			see [[#gap-percent]].

		: <dfn>normal</dfn>
		:: The value ''gap/normal'' represents
			a used value of ''1em'' on <a>multi-column containers</a>,
			and a used value of ''0px'' in all other contexts.
	</dl>

	Gutters effect a minimum spacing between items:
	additional spacing may be added by 'justify-content'/'align-content'.
	Such additional space effectively increases the size of these <a>gutters</a>.

	The exact handling of these properties varies by layout container:

	<dl>
		<dt id="gap-multicol"><a>multi-column containers</a>
		<dd>
			'column-gap' specifies the [=gutter=] between adjacent <a>column boxes</a>,
			see [[CSS-MULTICOL-1]].
			'row-gap' specifies the [=gutter=] between the rows of [=column boxes=] established by 'column-height',
			see [[CSS-MULTICOL-2]].

		<dt id="gap-flex"><a>flex containers</a>
		<dd>
			When applied to the <a>main axis</a>
			(e.g. 'column-gap' in a ''flex-flow/row'' <a>flex container</a>),
			indicates the [=gutter=] between items
			(as if an additional fixed-size margin were inserted
			between adjacent <a>flex items</a>
			in a single line).

			When applied to the <a>cross axis</a>
			(e.g. 'row-gap' in a ''flex-flow/row'' <a>flex container</a>),
			indicates the [=gutter=] between adjacent <a>flex lines</a>.

		<dt id="gap-grid"><a>grid containers</a>
		<dd>
			The 'row-gap' and 'column-gap' properties,
			when specified on a <a>grid container</a>,
			define the [=gutters=] between <a>grid rows</a> and <a>grid columns</a>,
			respectively.
			See [[css-grid-1#gutters]] for precise details.
	</dl>

	In all cases, the [=gutter=] disappears when it coincides with
	a [=fragmentation break=]. [[CSS-BREAK-3]]

	Note: Table boxes do not use the 'gap' properties
	to specify separation between their cells.
	Instead, they use the 'border-spacing' property,
	which has slightly different functionality:
	it inherits,
	and it also specifies the additional spacing between the outermost cells
	and the border of the table
	(similar to ''space-evenly'' rather than ''space-between'').

<h3 id='gap-shorthand'>
Gap Shorthand: the 'gap' property</h3>

	<pre class='propdef'>
	Name: gap
	Value: <<'row-gap'>> <<'column-gap'>>?
	Initial: see individual properties
	Applies to: <a>multi-column containers</a>, <a>flex containers</a>, <a>grid containers</a>
	Inherited: no
	Percentages: refer to corresponding dimension of the content area
	Computed value: see individual properties
	Animation type: by computed value type
	</pre>

	This property is a <a>shorthand</a> that sets 'row-gap' and 'column-gap' in one declaration.
	If <<'column-gap'>> is omitted,
	it's set to the same value as <<'row-gap'>>.

	<div class='example'>
		<figure>
			<img src="images/gutters-gaps.svg" alt="A diagram showing how margins and padding add to the visible gutter size" width="500" height="616">
		</figure>

		Note: The 'gap' property is only one component of the visible “gutter” or “alley” created between boxes.
		Margins, padding, or the use of distributed alignment
		may increase the visible separation between boxes
		beyond what is specified in 'gap'.
	</div>

<h3 id='gap-percent'>
Percentages In 'gap' Properties</h3>

	In general,
	gaps introduced by the 'gap' properties
	are intended to act like an empty item/track/etc
	with the gap's size;
	in other words,
	an author should be able to reproduce the effects of 'gap'
	by just inserting additional empty items/tracks/etc
	into the container.

	'gap' always resolves percentages against
	the corresponding size of the [=content box=]
	of the element.
	When this size is definite,
	the behavior is well-defined
	and consistent across layout modes.
	But since different layout modes treat [=cyclic percentage sizes=] for items/tracks/etc differently,
	'gap' does as well:

	: In Grid Layout
	::
		<a href="https://www.w3.org/TR/css-sizing-3/#percentage-sizing">As in the min size properties and margins/paddings</a> [[CSS-SIZING-3]],
		[=cyclic percentage sizes=] resolve against zero
		for determining intrinsic size contributions,
		but resolve against the box’s content box
		when laying out the box’s contents.

	: In Flex Layout
	::
		[=Cyclic percentage sizes=] resolve against zero in all cases.

<h3 id='gap-legacy'>
Legacy Gap Properties: the 'grid-row-gap', 'grid-column-gap', and 'grid-gap' properties</h3>

	The Grid Layout module was originally written with its own set of [=gutter=] properties,
	before all such properties were unified into the existing 'row-gap'/'column-gap' naming.
	For compatibility with legacy content,
	these grid-prefixed names must be supported as follows:

	* <dfn property>grid-row-gap</dfn> as a [=legacy name alias=] of the 'row-gap' property
	* <dfn property>grid-column-gap</dfn> as a [=legacy name alias=] of the 'column-gap' property
	* <dfn property>grid-gap</dfn> as a [=legacy name alias=] of the 'gap' property

<!--
████████     ███     ██████  ████████ ██       ████ ██    ██ ████████
██     ██   ██ ██   ██    ██ ██       ██        ██  ███   ██ ██
██     ██  ██   ██  ██       ██       ██        ██  ████  ██ ██
████████  ██     ██  ██████  ██████   ██        ██  ██ ██ ██ ██████
██     ██ █████████       ██ ██       ██        ██  ██  ████ ██
██     ██ ██     ██ ██    ██ ██       ██        ██  ██   ███ ██
████████  ██     ██  ██████  ████████ ████████ ████ ██    ██ ████████
-->

<h2 id='baseline-rules'>
Baseline Alignment Details</h2>

	Boxes in a <a>baseline-sharing group</a> are aligned to each other
	using their <a>alignment baselines</a>.
	For example, in horizontal writing modes,
	specifying ''align-content: baseline'' on table cells in the same row
	will align the baselines of their <a>first formatted lines</a>.
	This section defines exactly how baseline alignment is performed
	in consideration of the myriad baselines and <a>writing modes</a>
	that exist in internationalized modern CSS.

	A <dfn export>baseline set</dfn> is
	a set of baselines (alphabetic, central, etc.)
	associated with a common baseline table.
	Typically, a typesetting tradition will use only one of these,
	but different writing systems use different baselines,
	and mixing writing systems can result in using more than one
	within a single line.
	Refer to [[css-writing-modes-3#intro-baselines]]
	for more information on baselines and writing modes.

<h3 id='baseline-export'>
Determining the Baselines of a Box</h3>

	Each box,
	for a given axis,
	has potentially
	a <dfn export lt="first baseline set|first baselines">first baseline set</dfn>
	(and <dfn export lt="last baseline set|last baselines">last baseline set</dfn>)
	that nominally corresponds to the <a>baseline set</a> of
	the first/last line of text within the box.
	The <dfn export>alignment baseline</dfn>,
	which is the baseline used to align the box in its [=alignment context=],
	is one of the baselines in its [=baseline set=],
	usually the dominant baseline associated with the <a>shared alignment context</a>.
	(See the 'dominant-baseline' and 'alignment-baseline' properties in [[CSS-INLINE-3]].)

	The first and last <a>baseline sets</a> of a box
	are determined differently based on the layout model, as follows:

	<dl>
		<dt>line box
		<dd>
			The first/last [=baseline set=] of a line box
			is <a>generated</a> from the dominant baseline
			and the font settings of its [=root inline box=].

		<dt>block containers
		<dd>
			The first/last [=baseline set=] of a <a>block container</a>
			is taken from the first/last [=in-flow=] line box in the block container
			or the first/last [=in-flow=] block-level child in the block container
			that contributes a set of first/last baselines,
			whichever comes first/last.
			If there is no such line box or child,
			then the block container has no [=baseline set=].

			However, for legacy reasons
			if its 'baseline-source' is ''baseline-source/auto'' (the [=initial value=])
			a [=block-level=] or [=inline-level=] [=block container=]
			that is a [=scroll container=]
			always has a [=last baseline set=],
			whose baselines all correspond to its [=block-end=] [=margin edge=].

		<dt>multi-column containers
		<dd>
			The first [=baseline set=] of a <a>multi-column container</a>
			is the first [=baseline set=] of the [=column=] or [=multi-column spanner=]
			with the highest ([=block-start=]&ndash;most) baseline
			corresponding to the [=multi-column container=]'s [=alignment baseline=].
			If there is no such line box or child,
			then the multi-column container has no first [=baseline set=].

			The last [=baseline set=] is analogous,
			but uses the <em>last</em> [=baseline set=]
			and <em>lowest</em> ([=block-end=]&ndash;most) baseline.

		<dt>tables
		<dd>
			The first/last [=baseline set=] of a table box
			is the first/last [=baseline set=] of its first/last row.

			When finding the first/last baseline set of an inline-block,
			any baselines contributed by table boxes must be skipped.
			(This quirk is a legacy behavior from [[CSS2]].)

		<dt>table rows
		<dd>
			If any cells in the row participate in
			''first baseline''/''last baseline'' alignment
			along the [=inline axis=],
			the first/last [=baseline set=] of the row
			is <a>generated</a> from their shared <a>alignment baseline</a>
			and the row's <a>first available font</a>,
			after alignment has been performed.
			Otherwise, the first/last [=baseline set=] of the row
			is <a>synthesized</a> from the lowest and highest content edges of the cells in the row.
			[[!CSS2]]

			Spanning cells participate only in the first/last row that they span
			for the purpose of ''first baseline''/''last baseline''.

		<dt>flex containers
		<dd>
			See <a href="https://www.w3.org/TR/css3-flexbox/#flex-baselines">Flex Baselines</a> in [[!CSS-FLEXBOX-1]].

		<dt>grid containers
		<dd>
			See <a href="https://www.w3.org/TR/css3-grid-layout/#grid-baselines">Grid Baselines</a> in [[!CSS-GRID-1]].
	</dl>

	To <dfn local-lt=generate|generated export>generate baselines</dfn> for a box from a single baseline,
	use the baseline table from the font settings and <a>first available font</a> of that box,
	and align that baseline set to the given single baseline.

	If a box that participates in [=baseline alignment=]
	has no [=baseline set=],
	then its [=alignment baseline=] is [=synthesized=]
	according to the rules of the [=formatting context=] in which it participates.
	To <dfn lt="synthesize baseline|synthesized baseline" local-lt=synthesize|synthesized export>synthesize baselines</dfn> from a rectangle (or two parallel lines),
	synthesize the alphabetic baseline from the <a>line-under</a> line,
	and the central baseline by averaging the positions of the two edges or lines.
	See [[css-inline-3#baseline-synthesis]] for rules on synthesizing additional baselines.

	Note: The edges used to <a>synthesize</a> baselines from a box
	depend on their <a>formatting context</a>:
	inline-level boxes <a>synthesize</a> from their margin edges [[CSS-INLINE-3]],
	table cells <a>synthesize</a> from their content edges [[CSS2]],
	and grid and flex items <a>synthesize</a> from their border edges [[CSS-GRID-1]] [[CSS-FLEXBOX-1]].

	In general, the <a>writing mode</a> of the box, shape, or other object being aligned
	is used to determine the <a>line-under</a> and <a>line-over</a> edges for synthesis.
	However, when that <a>writing mode</a>’s
	<a>block flow direction</a> is parallel
	to the axis of the <a>alignment context</a>,
	an axis-compatible <a>writing mode</a> must be assumed:
	* If the box establishing the <a>alignment context</a>
		has a <a>block flow direction</a> that is orthogonal to the axis of the <a>alignment context</a>,
		use its <a>writing mode</a>.
	* Otherwise:
		* If the box’s own [=writing mode=] is vertical,
			assume ''horizontal-tb''.
		* If the box’s own [=writing mode=] is horizontal,
			assume ''vertical-lr'' if 'direction' is ''ltr''
			and ''vertical-rl'' if 'direction' is ''rtl''.

	For the purposes of finding the baselines of a box,
	it and all its [=in-flow=] descendants with a scrolling mechanism (see the 'overflow' property)
	must be considered as if scrolled to their initial scroll position.
	Additionally,
	if the position of a [=scroll container=]’s first/last baseline
	is outside its border edge,
	that baseline’s position is clamped to the border edge.

<h3 id='baseline-terms'>
Baseline Alignment Grouping</h3>

	A <dfn export>baseline-sharing group</dfn>
	is composed of boxes that participate in baseline alignment together.
	This is possible only if they both:

	<ul>
		<li>Share an <a>alignment context</a> along an axis perpendicular to the axis they're being baseline-aligned in.
			(For example, grid items with ''align-self: baseline'' are baseline-aligning along the grid’s block axis,
			and therefore participate with other items in their row.)
		<li>Have <a>compatible baseline alignment preferences</a>
			(i.e., the baselines that want to align are on the same side of the alignment context).
	</ul>

	Note: Boxes participating in <a>baseline content-alignment</a> and
	boxes participating in <a>baseline self-alignment</a>
	can be part of the same <a>baseline-sharing group</a>,
	and can thus align to each other.
	The difference between the two methods
	is in where extra space is inserted to perform the alignment
	(inside or outside the box’s own border).

	Boxes share an <dfn lt="shared alignment context|alignment context" export>alignment context</dfn>,
	along a particular axis,
	and established by a particular box,
	when they are:

	<ul>
		<li>table cells in the same row, along the table's row (inline) axis, established by the row box
		<!--baseline-align-column <li>table cells in the same column, along the table's column (block) axis, established by the column box -->
		<li>grid items in the same row, along the grid's row (inline) axis, established by the <a>grid container</a>
		<li>grid items in the same column, along the grid's column (block) axis, established by the <a>grid container</a>
		<li>flex items in the same flex line, along the flex container's main axis, established by the <a>flex container</a>
	</ul>

	Note: Conceptually,
	the inline-level boxes in a line box also share a self-alignment context
	and participate in a baseline-sharing group;
	however they only baseline-align in response to the 'vertical-align' property,
	not any of the properties defined in this module.
	See [[CSS-INLINE-3]].

	If a box spans multiple <a>shared alignment contexts</a>,
	then it participates in first/last baseline alignment
	within its start-most/end-most <a>shared alignment context</a> along that axis.
	For example, a table cell spanning three rows
	participates in <a>first-baseline alignment</a>
	with the table cells in the first row that it spans,
	or alternatively in <a>last-baseline alignment</a>
	with the table cells in the last row that it spans.

	The <a>baseline alignment preferences</a> of two boxes in a <a>baseline-sharing group</a> are <dfn lt="compatible baseline alignment preferences">compatible</dfn> if they have:

	* the same <a>block flow direction</a> and same <a>baseline alignment preference</a>
	* opposite <a>block flow direction</a> and opposite <a>baseline alignment preference</a>

<h3 id='align-by-baseline'>
Aligning Boxes by Baseline</h3>

	Given a set of [=alignment subjects=] and their baselines
	that all belong to a single <a>baseline-sharing group</a>,
	the [=alignment subjects=] are baseline-aligned as follows:

	1. Generate the <a>baseline-sharing group</a>’s baseline table
		from the <a>first available font</a> of the group’s [=alignment context=]
		and overlay also the mirror of this baseline table by aligning their central baselines.
		These are the baseline “grids” to which the [=alignment subjects=] will align.

	2. Align each [=alignment subject=] by its specified <a>alignment baseline</a>
		to the group’s baseline table
		or its mirror, whichever matches the [=alignment subject’s=] <a>line orientation</a>.
		Unless otherwise specified (e.g. via the 'alignment-baseline' property),
		the <a>alignment baseline</a> is the <a>dominant baseline</a> of the [=alignment context=].

	3. Position the aligned <a>baseline-sharing group</a> within the [=alignment container=]
		according to its <a>fallback alignment</a>.
		The [=fallback alignment=] of a [=baseline-sharing group=]
		is the [=fallback alignment=] of its items
		as resolved to [=physical directions=].

	4. For first/last <a>baseline <em>content</em>-alignment</a>,
		then add the minimum necessary extra space
		between the [=alignment container’s=] start/end content edge
		and the [=alignment subject’s=] edge
		to align the start/end margin edges of all the [=alignment containers=]
		in the [=alignment context=]
		while maintaining baseline alignment within the [=baseline-sharing group=].


<h2 id="staticpos-rect">
Appendix A: Static Position Terminology</h2>

	When both <a>inset properties</a> in a given axis are ''left/auto''
	on an <a href="https://www.w3.org/TR/CSS2/visuren.html#absolutely-positioned">absolutely positioned box</a>,
	CSS2 uses its <a>static position</a>
	to resolve its size and position.
	See <a href="https://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-width">CSS2.1&sect;10.3.7</a>.
	The <a>box alignment properties</a> modify these calculations,
	just as they do the sizing and positioning calculations in other layout modes.
	These modifications refer to a <dfn>static-position rectangle</dfn>,
	whose edges represent the <a>static position</a> of the box
	from each side of its <a>containing block</a>.

	The <a>static-position rectangle</a> and the <a>static positions</a> to which it corresponds
	are defined by the layout model of its “hypothetical box”:

	<dl>
		<dt>Block Layout
		<dd>
		The <a>static positions</a> of a <a>block-level box</a>
		are defined in [[CSS2]] Chapter 10.
		The <a>static-position rectangle</a> is a zero-thickness rectangle spanning between
		the inline-axis sides of the box’s <a>static-position containing block</a>
		(see <a href="https://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-width">CSS2&sect;10.3.7</a>);
		and positioned at its <a>block-start</a> <a>static position</a>
		(see <a href="https://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-height">CSS2&sect;10.6.4</a>).

		<dt>Inline Layout
		<dd>
		The <a>static positions</a> of an <a>inline-level box</a>
		are defined in [[CSS2]] Chapter 10.
		The <a>static-position rectangle</a> is a zero-thickness rectangle spanning between
		the <a>line-over</a>/<a>line-under</a> sides of the <a>line box</a>
		that would have contained its “hypothetical box”
		(see <a href="https://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-width">CSS2&sect;10.3.7</a>);
		and positioned at its <a>inline-start</a> <a>static position</a>.

		<dt>Flex Layout
		<dd>
		The <a>static-position rectangle</a> of the child of a <a>flex container</a>
		corresponds to the <a>content edges</a> of the <a>flex container</a>.
		See [[css-flexbox-1#abspos-items]].

		<dt>Grid Layout
		<dd>
		By default, the <a>static-position rectangle</a> of the child of a <a>grid container</a>
		corresponds to the <a>content edges</a> of the <a>grid container</a>.
		However, if that <a>grid container</a> also establishes
		the box’s actual <a>containing block</a>,
		then the <a>grid area</a> specified by the <a>grid-placement properties</a>
		establishes its <a>static-position rectangle</a> instead.
		See the <a href="https://www.w3.org/TR/css-grid-1/#static-position">static position of a grid container child</a> in [[!CSS-GRID-1]].
	</dl>

<!--
 ██████  ██     ██    ███    ██    ██  ██████   ████████  ██████
██    ██ ██     ██   ██ ██   ███   ██ ██    ██  ██       ██    ██
██       ██     ██  ██   ██  ████  ██ ██        ██       ██
██       █████████ ██     ██ ██ ██ ██ ██   ████ ██████    ██████
██       ██     ██ █████████ ██  ████ ██    ██  ██             ██
██    ██ ██     ██ ██     ██ ██   ███ ██    ██  ██       ██    ██
 ██████  ██     ██ ██     ██ ██    ██  ██████   ████████  ██████
-->

<h2 id="changes">
Changes</h2>

	Changes since the <a href="https://www.w3.org/TR/2025/WD-css-align-3-20250311/">11 March 2025 Working Draft</a> include:
	* Clarify that [[#auto-safety-position]] applies when 'position-area' alters the [=used value=] of ''align-self/normal''.
	* Allow absolutely positioned boxes to honor alignment even when overflowing into
		the scrollable overflow area of a scroll container containing block.
		(<a href="https://github.com/w3c/csswg-drafts/issues/12106">Issue 12106</a>)

	See also <a href="https://www.w3.org/TR/2025/WD-css-align-3-20250311/#changes">previous changes</a>.

<h2 id="privacy">
Privacy Considerations</h2>

	As a simple layout spec,
	this introduces no new privacy considerations.

<h2 id="security">
Security Considerations</h2>

	As a simple layout spec,
	this introduces no new security considerations.

<h2 class=no-num id="acknowledgments">
Acknowledgments</h2>

	Special thanks goes to David Baron, Javier Fernandez, Markus Mielke, Alex Mogilevsky,
	and the participants in the CSSWG's March 2008 F2F alignment discussions
	for their contributions to the alignment model described herein,
	and to Melanie Richards for her illustrations of the various <a href="#alignment-values">alignment keywords</a>.
